package cn.it.shop.action;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.it.shop.pojo.Category;
import cn.it.shop.service.CategoryService;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.util.ValueStack;
/*
 *  在没有整合的时候是Struts自己创建Action
 * */
@Controller
@Scope("prototype")
public class CategoryAction extends BaseAction<Category>{
	
	public CategoryAction(){
		System.out.println("CategoryAction()");
	}

	public String save(){
		// 要从session中获取管理员的信息
		categoryService.save(model);
		// 在更新(删除、添加、修改),都需要同步到application中
		application.put("categoryList", categoryService.query());
		return "query";
	}
	// 如何获取相关的Map集合
	public String query(){
		List<Category> categoryList=categoryService.queryFetchAccount(model.getType());
		request.put("categoryList", categoryList);
		return "query";
	}
	
	public void update(){
		System.out.println(model.getType());
		categoryService.update(model);
	}
	
	public String goIndex(){
		return "aindex";	
	}
}
